﻿using SPSDeploy.Extensions.Controllers;
using System.Xml.Linq;
using System.Xml.XPath;

namespace SPSDeploy.Extensions.Modules.Update
{
    /// <summary>
    /// Service application proxy update module
    /// </summary>
    internal class ServiceApplicationProxyModule : BaseModule
    {

        /// <summary>
        /// Initialization
        /// </summary>
        /// <param name="controller"></param>
        internal ServiceApplicationProxyModule(BaseController controller)
            : base(controller)
        {
        }

        /// <summary>
        /// Execute module
        /// </summary>
        /// <param name="parent"></param>
        internal override void Execute(XElement parent)
        {
            if (parent != null)
            {
                foreach (XElement element in parent.XPathSelectElements("adds/serviceApplicationProxy"))
                    controller.OnProgressMessage(MessageType.Warning, string.Format("Service application proxy '{0}' creation is not supported.", element.Attribute("name").Value));
                foreach (XElement element in parent.XPathSelectElements("deletes/serviceApplicationProxy"))
                    controller.OnProgressMessage(MessageType.Warning, string.Format("Service application proxy '{0}' removal is not supported.", element.Attribute("name").Value));
                controller.OnProgressMessage("Service application proxy information updated.");
            }
        }

    }
}